<?php

	$url = $_REQUEST['url'];

	$expected=array(
			'request'
		,	'service'
		,	'version'
		,	'outputformat'
		,	'TypeName'

		,	'srs'
		,	'format'
		,	'bbox'
		,	'width'
		,	'height'
		,	'styles'
		,	'query_layers'
		,	'x'
		,	'y'
		,	'info_format'
		,	'feature_count'
		,	'exceptions'
		,	'servicename'
		,	'layers'
		,	'FILTER'
		,	'REQUEST'
		,	'TYPENAME'
	);
	
	// Initialize allowed variables
	foreach ($expected as $formvar)
		$$formvar = (isset(${"_$_SERVER[REQUEST_METHOD]"}[$formvar])) ? ${"_$_SERVER[REQUEST_METHOD]"}[$formvar]:NULL;	

	$extra = "?";
	foreach($expected as $name){
		if ($$name != '') {
			$extra .= $name . "=" . urlencode($$name) . "&";
		}
	}
#print $url . $extra;
#exit();
#	header ("content-type: text/xml");

	$opts = array(
		'http'=>array(
			'method'=>"GET",
			'header'=>"User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8" . 
								"Host: birdlaa2.memset.net:8080"
		)
	);
	
	$context = stream_context_create($opts);
#exit();
#	print file_get_contents($url . $extra, false, $context); 
#	print file_get_contents("http://birdlaa2.memset.net:8080/");
#	print file_get_contents("http://birdlaa2.memset.net:8080/", false, $context);

$fp = fsockopen("birdlaa2.memset.net", 8080, $errno, $errstr, 6);
if (!$fp) {
    echo "$errstr ($errno)<br />\n";
} else {
//    $out = "GET / HTTP/1.1\r\n";
    $out = "Host: birdlaa2.memset.net:8080\r\n";
//    $out .= "Connection: Close\r\n\r\n";
		$out .= "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8";
		$out .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
		$out .= "Accept-Language:	en-us,en;q=0.5";
		$out .= "Accept-Encoding:	gzip,deflate";
		$out .= "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
		$out .= "Keep-Alive: 115";
		$out .= "Connection: keep-alive";
    fwrite($fp, $out);
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}
?>